package com.bwie.auth.controller;


import com.bwie.auth.service.AuthService;
import com.bwie.common.domain.User;
import com.bwie.common.domain.request.LoginRequest;
import com.bwie.common.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/auth")
public class AuthController {
    @Autowired
    private AuthService authService;

    /**
     * 登录
     * @param loginRequest
     * @return
     */
    @PostMapping("login")
    public Result login(@RequestBody LoginRequest loginRequest){
        Result result = authService.login(loginRequest);
        return result;
    }

    /**
     * 获取用户的信息
     * @return
     */
    @GetMapping("userInfo")
    public Result userInfo(){
        User user = authService.userInfo();
        return Result.success(user);
    }
}
